function getVoteItem(app) {
		$("#app").val(app);
		$("#div_voteItem").load("getVoteItem.cms?app="+app);
}
function postVote(voteId) {
	var title=$("#title").val();
	var body=$("#body").val();
	var picUrl=$("#votePicUrl").val();
	var app=$("#app").val();
	var voteType=$(":radio[name='RadioVoteType'][checked]").val();
	if(picUrl==""||title==""||body==""){
		alert("请填写完整");
		return;
	}
	if(app=='03'){
		if(voteType=="" || voteType==null){
			alert("请选择投票项目");
			return;
		}
	}
	$.post("saveVote.cms",{
		identifier : voteId,
		app:app,
		title : title,
		body : body,
		picUrl : picUrl,
		voteType:voteType
	},function(data){
		if(data=="success"){
			$("#div_voteItem").load("getVoteItem.cms?app="+app);
			closeTanchu();
		}
		
	});

}

function closeTanchu() {
	$(".tanchu").hide().remove();
	$(".mask").hide();
}
function voteUploadImg2(){
	var filepath=$("#uploadImgVote2").val(); 
	var extStart=filepath.lastIndexOf("."); 
	var ext=filepath.substring(extStart,filepath.length).toUpperCase(); 
	if(ext!=".PNG"&&ext!=".JPG"&&ext!=".JPEG"&&ext!=".GIF"){ 
		alert("图片限于png,jpeg,jpg,gif格式"); 
		return ; 
	}
	$("#vote_upload_img_form2").ajaxSubmit({
		dataType : 'json',
		cache : false,
		success : function(data) {
			
		$("#votePicUrl").val(data.pictureUrl);
		},
		error : function(err) {
			alert(err);
		}
	});
	return false;
}

//上移
function addVoteSort(voteId,page) {
	var app = $("#app").val();
	$.post("addVoteSort.cms?voteId=" + voteId,
			function() {
				$("#div_voteItem").load("getVoteItem.cms?app="+app+"&page="+page);
	});
}
//下移
function downVoteSort(voteId,page) {
	var app = $("#app").val();
	$.post("downVoteSort.cms?voteId=" + voteId ,
			function() {
		$("#div_voteItem").load("getVoteItem.cms?app="+app+"&page="+page);
	});
}
function showModifyVote(voteId) {
	/*$("#div_postVote").load("getVoteById.cms?id="+voteId,function(){
		$("#tr_voteItem").show();
	});*/
	$.tcMask({url:"getVoteById.cms",params:{id:voteId}});
	$("#tr_voteItem").show();
}

function modifyVoteItem(id,voteId){
	$.tcMask({url:"toAddVoteItem.cms",params:{voteItemId:id,voteId:voteId}});
}

function showPostVote(app) {
	//$("#div_postVote").load("toAddVote.cms?app="+app);
	//alert(app);
	$.tcMask({url:"toAddVote.cms",params:{app:app}});

}
//显示修改列项
function showAddVoteItem(voteId) {
	$.tcMask({url:"toAddVoteItem.cms",params:{voteId:voteId}});
}
function showModifyVoteItem(voteItemId, voteTitle,voteId) {
	$("#div_addVote").hide();
	$.get("getVoteItemById.cms?voteItemId=" + voteItemId, function(data) {
		$("#voteItemId").val(voteItemId);
		$("#div_postVoteItem").show();
		$("#btn_vote_item").val("修改");
		$("#label_vote_title").text(voteTitle);
		$("#voteItemTitle").val(data[0].title);
		$("#voteItemPicUrl").val(data[0].picUrl);
		$("#pic_item").attr("src",data[0].picUrl)
		$("#voteId").val(voteId);
		$("#desc").val(data[0].desc);
	}, 'json');
	
}
//添加列项
function saveVoteItem() {
	var voteItemId = $("#voteItemId").val();
	var title=$("#voteItemTitle").val();
	var picUrl=$("#voteItemPicUrl").val();
	var desc=$("#desc").val();
	var app=$("#app").val();
	var voteId=$("#voteId").val();
	if(picUrl==""||title==""){
		alert("请填写完整");
		return;
	}
	$.post("saveVoteItem.cms",{
		identifier : voteItemId,
		voteId:voteId,
		title : title,
		picUrl : picUrl,
		desc:desc
	},function(data){
		if(data=="success"){
			$("#div_voteItem").load("getVoteItem.cms?app="+app);
			closeTanchu();
		}
		
	});
}
function closeAddVoteItem() {
	
}
//结束
function closeVote(voteId,page){
	$.post("closeVote.cms?voteId=" + voteId,
			function() {
				$("#div_voteItem").load("getVoteItem.cms?page="+page+"&app="+$("#app").val());
			});
}
//可用
function openVote(voteId,page){
	$.post("openVote.cms?voteId=" + voteId,
			function() {
				$("#div_voteItem").load("getVoteItem.cms?page="+page+"&app="+$("#app").val());
			});
}

function voteUploadImg(){
	var filepath=$("#uploadImgVote").val(); 
	var extStart=filepath.lastIndexOf("."); 
	var ext=filepath.substring(extStart,filepath.length).toUpperCase(); 
	if(ext!=".PNG"&&ext!=".JPG"&&ext!=".JPEG"&&ext!=".GIF"){ 
		alert("图片限于png,jpeg,jpg,gif格式"); 
		return ; 
	}
	$("#vote_upload_img_form").ajaxSubmit({
		dataType : 'json',
		cache : false,
		success : function(data) {
			$("#voteItemPicUrl").val(data.pictureUrl);
		},
		error : function(err) {
			alert(err);
		}
	});
	return false;
}

//删除子项
function deleteVoteItem(voteItemId,page){
	 var r=confirm("确定删除吗？");
	 if(r==true){
		 $.get("deleteVoteItem.cms?voteItemId=" + voteItemId, function() {
				$("#div_voteItem").load("getVoteItem.cms?page="+page+"&app="+$("#app").val());
			});
	 }
}
//删除投票项
function delVote(voteId,sort,page) {
	 var r=confirm("确定删除吗？");
	 var app = $("#app").val();
	 if(r==true){
		 $.get("deleteVote.cms?voteId=" + voteId+"&sort="+sort+"&app="+app, function() {
				$("#div_voteItem").load("getVoteItem.cms?page="+page+"&app="+app);
			});
	 }
	
}

